package com.bawei.composeui2207a.day01

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.LocationOn
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.bawei.composeui2207a.R

/**
 * 作者：赵亮
 * 时间：2024/12/10 16:23
 * 功能：图片
 */
@Composable
fun Page4() {

    Column {
        // Icon 图标
        Icon(
            modifier = Modifier.size(100.dp),
            tint = Color.Red,                       // 图标颜色
            imageVector = Icons.Default.LocationOn,   // 设置图标 心 + Home
            contentDescription = null
        )
        /*Icon(
            painter = painterResource(
                id = R.drawable.profile_picture
            ), contentDescription = null
        )*/

        // Image 图片
        Image(
            painter = painterResource(id = R.drawable.profile_picture),
            contentDescription = null)
        // 大小 与 拉伸 contentScale
        Image(
            modifier = Modifier
                .fillMaxWidth()
                .background(Color.Red)
                .height(200.dp),
            painter = painterResource(id = R.drawable.profile_picture),
            contentDescription = null,
            contentScale = ContentScale.Crop                // 拉伸模式，拉满容器
        )

        // 圆角 圆形
        Row {
            Image(
                modifier = Modifier
                    .size(80.dp)
                    .clip(RoundedCornerShape(15.dp)),                       // 圆角
                painter = painterResource(id = R.drawable.profile_picture),
                contentDescription = null
            )
            Image(
                modifier = Modifier
                    .size(80.dp)
                    .clip(RoundedCornerShape(topEnd = 20.dp, bottomEnd = 20.dp)),                       // 圆角
                painter = painterResource(id = R.drawable.profile_picture),
                contentDescription = null
            )
            Image(
                modifier = Modifier
                    .size(50.dp)
                    .clip(CircleShape),                                     // 圆形
                painter = painterResource(id = R.drawable.profile_picture),
                contentDescription = null
            )
        }

        // AsyncImage  网络图片
    }
}

@Preview(showSystemUi = true)
@Composable
fun Page4Preview() {
    Page4()
}

